<template>
	<view>
		<view class="bg-white">
			<view
				class="flex justify-between align-center pad-10 font-14"
				style="border-bottom: 1px #e6e6e6 solid;"
			>
				<view>
					<text>任务单号：</text>
					<text>{{ repairTaskNum }}</text>
				</view>
				
				<view class="mar-t-5">
					<text>日期：</text>
					<text>{{ dates }}</text>
				</view>
			</view>
			
			<view class="font-14 pad-10">
				<view>
					<text>客户：</text>
					<text>{{ currentRow.Customer.CName }}</text>
				</view>
				
				<view class="mar-t-5">
					<text>车号：</text>
					<text>{{ cartNum }}</text>
				</view>
			</view>
		</view>
		
		<view class="bg-white pad-10 mar-t-10 pad-b-20">
			<CustomStep
				v-if="list.length > 0"
				:stepList="list"
				titleProp="VehicleNumber"
				contentProp="AuditDate"
				descProp="Reason"
			/>
			
			<u-empty v-else mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="~ 暂无数据" />
		</view>
	</view>
</template>

<script>
	import CustomStep from '@/components/CustomStep/index'
	import Utils from '@/utils/utils'
	
	import { mapState } from 'vuex'
	import { checkLogin } from '@/utils/lib'
	import { getDetails } from '@/apis/workOrderManage/index'
	
	export default {
		components: {
			CustomStep
		},
		
		computed: {
			...mapState({
				token: state => state.user.token,
				longitude: state => state.user.longitude,
				latitude: state => state.user.latitude,
				textMsgList: state => state.repair.textMsgList,
				pictureList: state => state.repair.pictureList,
				voiceList: state => state.repair.voiceList,
				videoList: state => state.repair.videoList,
				repairList: state => state.repair.repairList
			})
		},
		
		data() {
			return {
				RepairTaskId: null, // 任务详情id，用来查询任务详情
				RepairOrderId: null, // 维修详情id，用来查询维修详情
				currentRow: null, // 上一页的列表中工单信息
				details: null, // 详情
				dates: '', // 日期
				customerName: '', // 客户名称
				cartNum: '', // 车号
				repairTaskNum: null, // 任务单号
				list: [], // 列表
			}
		},
		
		onLoad(options) {
			this.RepairTaskId = options.RepairTaskId
			this.RepairOrderId = options.RepairOrderId
			this.currentRow = JSON.parse(options.currentRow)
		},
		
		onShow() {
			// 校验是否登录
			checkLogin()
		},
		
		mounted() {
			// 查询工单详情
			this.findOrderDetails()
		},
		
		methods: {
			// 查询工单详情
			findOrderDetails() {
				let params = {
					id: this.RepairOrderId,
					token: this.token,
					location: this.longitude + ',' + this.latitude
				}
				
				Utils.loading('数据加载中...')
				
				getDetails(params).then(res => {
					uni.hideLoading()
					this.list = res.Result
					this.cartNum = res.Result[0].VehicleNumber
					this.repairTaskNum = res.Result[0].RepairTaskNum
					this.dates = res.Result[0].CreateDate
				}).catch(err => {
					uni.hideLoading()
				})
			},
		}
	}
</script>

<style>

</style>
